package com.lin.missyou.service;

import com.lin.missyou.core.LocalUser;
import com.lin.missyou.model.User;
import com.lin.missyou.repository.UserRepository;
import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class UserService {

    @Autowired
    private UserRepository userRepository;

    public User getUserById(Long uid){
        return userRepository.findFirstById(uid);
    }

    public void updateUserInfo(Map<String, Object> userInfo){
        Long id = LocalUser.getUser().getId();
        User user = userRepository.findFirstById(id);
        user.setNickname(userInfo.get("nickName").toString());
        user.setWxProfile(userInfo);

        this.userRepository.save(user);

    }
}
